<html>
<head>
	<meta charset="UTF-8">
	<meta content="IE=edge" http-equiv="X-UA-Compatible">
	<meta content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no, width=device-width" name="viewport">
	<title>2809：[Apio2012]dispatching</title>
	<!-- css -->
	<link href="../css/base.min.css" rel="stylesheet">
	<link href="../css/project.min.css" rel="stylesheet">
	
	<!-- favicon -->
	<!-- ... -->
</head>
<body class="page-brand">
	<header class="header header-transparent header-waterfall ui-header">
		<ul class="nav nav-list pull-left">
			<li>
				<a data-toggle="menu" href="#menu">
					<span class="icon icon-lg">menu</span>
				</a>
			</li>
		</ul>
		<a class="header-logo header-affix-hide margin-left-no margin-right-no" data-offset-top="213" data-spy="affix">[Apio2012]dispatching</a>
		<span class="header-logo header-affix margin-left-no margin-right-no" data-offset-top="213" data-spy="affix">[Apio2012]dispatching</span>
	</header>
	<nav aria-hidden="true" class="menu" id="menu" tabindex="-1">
		<div class="menu-scroll">
			<div class="menu-content">
				<a class="menu-logo" href="../index.html">BZOJ离线题库</a>
				<ul class="nav">
					<li>
						<a class="waves-attach" data-toggle="collapse" href="#problems">题目</a>
						<ul class="menu-collapse collapse in" id="problems">
							<li>
								<a class="waves-attach" href="../index.html">主页</a>
							</li>
							<li>
								<a class="waves-attach" href="../list.html">题目列表</a>
							</li>
						</ul>
					</li>
					<li>
						<a class="collapsed waves-attach" data-toggle="collapse" href="#about">关于</a>
						<ul class="menu-collapse collapse" id="about">
							<li>
								<a class="waves-attach" href="../about.html">关于此项目</a>
							</li>
						</ul>
					</li>
					
				</ul>
			</div>
		</div>
	</nav>
	<main class="content">
		<div class="content-header ui-content-header">
			<div class="container">
				<h1 class="content-heading">
                [Apio2012]dispatching                </h1>
                <p>时间限制：10s&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  空间限制：128MB</p>			</div>
		</div>
		<div class="container">
			<section class="content-inner margin-top-no">
				<div class="row">
					<div class="col-lg-13 col-md-13">
						<div class="card margin-bottom-no">
							<div class="card-main">
								<div class="card-inner">
									
                                <h3>题目描述</h3><p><div>
<div style="margin: 0cm -3pt 0pt 42pt; line-height: 12pt" align="left"><span style="font-size: medium"><span style="color: black">在一个忍者的帮派里，一些忍者们被选中派遣给顾客，然后依据自己的工作</span><span style="color: black">获取报偿。</span><span style="color: black">在这个帮派里，有一名忍者被称之为</span><span style="color: black">&nbsp;Master</span><span style="color: black">。除了</span><span style="color: black">&nbsp;Master</span><span style="color: black">以外，每名忍者</span><span style="color: black">都有且仅有一个上级。为保密，同时增强忍者们的领导力，所有与他们工作相关</span><span style="color: black">的指令总是由上级发送给他的直接下属，而不允许通过其他的方式发送。</span><span style="color: black">现在你要招募一批忍者，并把它们派遣给顾客。你需要为每个被派遣的忍者 支付一定的薪水，同时使得支付的薪水总额不超过你的预算。另外，为了发送指令，你需要选择一名忍者作为管理者，要求这个管理者可以向所有被派遣的忍者 发送指令，在发送指令时，任何忍者（不管是否被派遣）都可以作为消息的传递 人。管理者自己可以被派遣，也可以不被派遣。当然，如果管理者没有被排遣，</span><span style="color: black">就不需要支付管理者的薪水。</span><span style="color: black">你的目标是在预算内使顾客的满意度最大。这里定义顾客的满意度为派遣的</span><span style="color: black">忍者总数乘以管理者的领导力水平，其中每个忍者的领导力水平也是一定的。</span><span style="color: black">写一个程序，给定每一个忍者</span><i><span style="color: black"> i</span></i><span style="color: black">的上级</span><i><span style="color: black"> B</span></i><i><span style="color: black">i</span></i><i><span style="color: black">，薪水</span></i><i><span style="color: black">Ci</span></i><i><span style="color: black">，领导力</span></i><i><span style="color: black">L i</span></i><i><span style="color: black">，以及支付给</span></i><span style="color: black">忍者们的薪水总预算</span><i><span style="color: black">&nbsp;M</span></i><span style="color: black">，输出在预算内满足上述要求时顾客满意度的最大值。</span></span></div>
</div>
<p><span style="font-size: medium"><br clear="all" />
</span>&nbsp;</p>
<div>
<div style="margin: 0cm -1.5pt 0pt 42pt; line-height: 14.25pt" align="left"><span style="font-size: medium"><span style="color: black">1 </span><span style="color: black">&nbsp;&le;<i>N</i> &le; 100,000 <span style="font-size: medium"><span style="color: black">忍者的个数；</span></span></span></span></div>
<div style="margin: 0cm -1.5pt 0pt 42pt; line-height: 14.25pt" align="left"><span style="font-size: medium"><span style="color: black">1 </span><span style="color: black">&nbsp;&le;<i>M</i> &le; 1,000,000,000&nbsp;<span style="font-size: medium"><span style="color: black">薪水总预算；</span></span>&nbsp;</span></span></div>
<div style="margin: 0cm -1.1pt 0pt 0cm; line-height: 1pt" align="left"><span style="font-size: medium"><span style="color: black">&nbsp;</span></span></div>
<div style="margin: 0cm -1.5pt 0pt 42pt; line-height: 14.25pt" align="left"><span style="font-size: medium"><span style="color: black">0 </span><span style="color: black">&nbsp;&le;<i>B</i></span></span><span style="font-size: medium"><i><span style="color: black">i &lt; i&nbsp; <span style="font-size: medium"><span style="color: black">忍者的上级的编号；</span></span></span></i></span></div>
</div>
<div>
<div style="margin: 0cm -1.5pt 0pt 42pt; line-height: 14.25pt; text-align: left" align="left"><span style="font-size: medium"><span style="color: black">1 </span><span style="color: black">&nbsp;&le;<i>C</i></span><i><span style="color: black">i &le; M </span></i><span style="color: black">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: black">忍者的薪水；</span></span></div>
<div style="margin: 0cm -1.5pt 0pt 42pt; line-height: 14.25pt; text-align: left" align="left"><span style="font-size: medium"><span style="color: black">1 </span><span style="color: black">&nbsp;&le;<i>L</i></span><i><span style="color: black">i &le; 1,000,000,000 </span></i><span style="color: black">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: black">忍者的领导力水平。</span></span></div>
<div style="margin: 0cm -1.1pt 0pt 0cm; line-height: 10pt" align="left"><span style="font-size: medium"><span style="color: black">&nbsp;</span></span></div>
<div style="margin: 0cm -1.1pt 0pt 0cm; line-height: 5pt" align="left"><span style="font-size: medium"><span style="color: black">&nbsp;</span></span></div>
</div>
<p></p></p><hr/><h3>输入格式</h3><p><div style="margin: 11.75pt -3pt 0pt 42pt; line-height: 14.25pt" align="left"><span style="font-size: medium"><span style="color: black">从标准输入读入数据。</span></span></div>
<div style="margin: 0cm -1.1pt 0pt 0cm; line-height: 1pt" align="left"><span style="font-size: medium"><span style="color: black">&nbsp;</span></span></div>
<div style="margin: 0cm -3pt 0pt 42pt; line-height: 13.75pt; text-align: left" align="left"><span style="font-size: medium"><span style="color: black">第一行包含两个整数</span><i><span style="color: black">&nbsp;N</span></i><span style="color: black">和</span><i><span style="color: black"> M</span></i><span style="color: black">，其中</span><i><span style="color: black"> N</span></i><span style="color: black">表示忍者的个数，</span><i><span style="color: black">M</span></i><span style="color: black">表示薪水的总预</span></span><span style="font-size: medium"><span style="color: black">算。</span></span></div>
<div style="margin: 0cm -1.1pt 0pt 0cm; line-height: 1pt" align="left"><span style="font-size: medium"><span style="color: black">&nbsp;</span></span></div>
<div style="margin: 0cm -3pt 0pt 42pt; line-height: 13.75pt; text-align: left" align="left"><span style="font-size: medium"><span style="color: black">接下来</span><i><span style="color: black">&nbsp;N</span></i><span style="color: black">行描述忍者们的上级、薪水以及领导力。其中的第</span><i><span style="color: black">&nbsp;i</span></i><span style="color: black">&nbsp;</span><span style="color: black">行包含三个整</span></span> <span style="font-size: medium"><i><span style="color: black">B</span></i></span><span style="font-size: medium"><i><span style="color: black">i , C i , L i</span></i><i><span style="color: black">分别表示第</span></i><i><span style="color: black">i</span></i><i><span style="color: black">个忍者的上级，薪水以及领导力。</span></i><i><span style="color: black">Master</span></i><i><span style="color: black">满足</span></i><i><span style="color: black">B i = 0</span></i><i><span style="color: black">，</span></i></span><span style="font-size: medium"><span style="color: black">并且每一个忍者的老板的编号一定小于自己的编号</span><span style="color: black"> <i>B</i></span></span><span style="font-size: medium"><i><span style="color: black">i &lt; i</span></i><i><span style="color: black">。</span></i></span></div>
<p><span style="font-size: medium"><br clear="all" />
</span>&nbsp;</p>
<div></div></p><hr/><h3>输出格式</h3><p><div>
<div style="margin: 0cm -3pt 0pt 42pt; line-height: 14.25pt" align="left"><span style="font-size: medium"><span style="color: black">输出一个数，表示在预算内顾客的满意度的最大值。</span></span></div>
<div style="margin: 0cm -1.1pt 0pt 0cm; line-height: 10pt" align="left"><span style="font-size: medium"><span style="color: black">&nbsp;</span></span></div>
<div style="margin: 0cm -1.1pt 0pt 0cm; line-height: 10pt" align="left"><span style="font-size: medium"><span style="color: black">&nbsp;</span></span></div>
</div></p><hr/><h3>样例输入</h3><pre> 
5  4
0  3 3
1  3 5
2  2 2
1  2 4
2  3 1
</pre><hr/><h3>样例输出</h3><pre>6 
 
 </pre><hr/><h3>提示</h3><p><p><br />
如果我们选择编号为 1的忍者作为管理者并且派遣第三个和第四个忍者，薪水总和为 4，没有超过总预算&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 4。因为派遣了&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 2&nbsp;&nbsp; 个忍者并且管理者的领导力为&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 3，<br />
用户的满意度为 2&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ，是可以得到的用户满意度的最大值。</p></p><hr/><h3>题目来源</h3><p>没有写明来源</p>
								</div>
							</div>
						</div>
					</div>
				</div>
				
				
			</section>
		</div>
	</main>

	<div class="fbtn-container">
		<div class="fbtn-inner">
			<a class="fbtn fbtn-lg fbtn-brand-accent waves-attach waves-circle waves-light waves-effect" data-toggle="dropdown" aria-expanded="true"><span class="fbtn-text fbtn-text-left">Menu</span><span class="fbtn-ori icon">apps</span><span class="fbtn-sub icon">close</span></a>
			<div class="fbtn-dropup">
				<a class="fbtn fbtn-brand waves-attach waves-circle waves-light waves-effect" href="../list.html" target="_self"><span class="fbtn-text fbtn-text-left">题目列表</span><span class="icon">menu</span></a>
				<a class="fbtn fbtn-green waves-attach waves-circle waves-effect" href="../index.html" target="_self"><span class="fbtn-text fbtn-text-left">返回主页</span><span class="icon">home</span></a>
				<a class="fbtn waves-attach waves-circle waves-effect" href="http://www.lydsy.com/JudgeOnline/submitpage.php?id=2809" target="_blank"><span class="fbtn-text fbtn-text-left">提交代码</span><span class="icon">send</span></a>
				<a class="fbtn fbtn-orange waves-attach waves-circle waves-effect" href="http://www.lydsy.com/JudgeOnline/wttl/wttl.php?pid=2809" target="_blank"><span class="fbtn-text fbtn-text-left">试题讨论</span><span class="icon">chat</span></a>
				
			</div>
		</div>
	</div>

	<!-- js -->
	<script src="../js/jquery.min.js"></script>
	<script src="../js/base.min.js"></script>
	<script src="../js/project.min.js"></script>
</body>
</html>